import { createStore } from 'vuex'

export default createStore({
  state: {
    // 存储token及登录用户基本信息
    Authorization:localStorage.getItem('token')? localStorage.getItem('token') : '',
    userInfo: localStorage.getItem('user') ? localStorage.getItem('user') : '',
  },
  getters: {
  },
  mutations: {
    //注册处理函数，在login组件的login方法上使用this.$store.commit('login',data);
    loginToken(state,token){
      state.Authorization = token;
      localStorage.setItem('token', token);
    },
    loginUser(state,user){
      state.userInfo = user;
      localStorage.setItem('user', user);
    }
  },
  actions: {
  },
  modules: {
  }
})
